package jkstatus

import (
	"jkgo/jk/jkprotocol"
	"net"
)

type MsgQueueItem struct {
	Proto jkprotocol.JKProtoV6
	Conn  net.Conn
}

type MsgQueue struct {
	List  map[int64]*MsgQueueItem
}

func NewMsgQueue(size int) *MsgQueue {
	return &MsgQueue{
		List: make(map[int64]*MsgQueueItem, size),
	}
}

func (mq *MsgQueue) Add(item *MsgQueueItem) error {
	mq.List[item.Proto.H.Transaction] = item
	return nil
}

func (mq *MsgQueue) Find(trans int64) *MsgQueueItem {
	return mq.List[trans]
}

func (mq *MsgQueue) Remove(trans int64) {
	mq.List[trans] = nil
}
